<template>
	<view>
		<button @click="onSetTimeOut()" type="primary">单次定时器setTimeOut</button>
		<button @click="onSetTimeOut('cys',1)">启动带参定时器</button>
		<button @click="onClearTimeOut()" type="warn">取消单次定时器clearTimeOut</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				name:'zhangsann',
				time1:null,
			}
		},
		methods: {
			onSetTimeOut(){
				console.log("onSetTimeOut()");
				this.timer1=setTimeout(()=>{
					console.log("onSetTimeOut() callback");
					// 
					console.log("onSetTimeOut() callback end");
				},3000);
			},
			// onSetTimeOut(username,pwd){
			// 	console.log("onSetTimeOut()",username,pwd);
			// 	// ()=>{ }
			// 	setTimeout((x,y)=>{
			// 		console.log("-------callback",x,y);
			// 	},2000,username,pwd)
			// },
			
			onClearTimeOut(){
				console.error("onClearTimeOut() 取消计时器");
				clearTimeout(this.timer1);
			}
			
		}
	}
</script>

<style>
button{
	margin:10rpx;
}
</style>
